package com.kgc.utils;

public class PageUnit {



    private int pageNo = 1;        //当前页码
    private int pageSum = 0;    //总页数
    private int pageSize = 2;         //每页展示记录数
    private int totalCount;            //记录总条数

    public PageUnit(int total) {
        this.totalCount=total;
        this.pageSum=this.totalCount%this.pageSize==0?this.totalCount/this.pageSize:this.totalCount/this.pageSize+1;
        //处理临界值，避免接受超出范围值
        if(this.pageNo<1){
            this.pageNo=1;
        }
        if(this.pageNo>this.pageSum){
            this.pageNo=this.pageSum;
        }
    }

    public int start(){
        return (this.pageNo-1)*this.pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSum() {
        return pageSum;
    }

    public void setPageSum(int pageSum) {
        this.pageSum = pageSum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
}
